package com.sweet.fourtimeoa.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sweet.fourtimeoa.mapper.NoticeMapper;
import com.sweet.fourtimeoa.pojo.dto.AnnouncementDto;
import com.sweet.fourtimeoa.pojo.entity.Announcements;
import com.sweet.fourtimeoa.pojo.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl {
    @Autowired
    private NoticeMapper noticeMapper;

    public PageVo<AnnouncementDto> NoticeUser(Integer pageNum,
                                              Integer pageeSize){
        //1.开启自动分页
        PageHelper.startPage(pageNum,pageeSize);
        Page<AnnouncementDto> list=(Page<AnnouncementDto>) noticeMapper.NoticeUser();
        PageVo<AnnouncementDto> PageVo=new PageVo<>();
        PageVo.setPageNum(list.getPageNum());
        PageVo.setPageSize(list.getPageSize());
        PageVo.setTotal(list.getTotal());
        PageVo.setList(list.getResult());
        PageVo.setPages(list.getPages());
        System.out.println();
        return PageVo;
    }
    public boolean NoticeAdd(Announcements announcements){
        return noticeMapper.NoticeAdd(announcements);
    }
    public boolean NoticeDelete(Integer id){
        return noticeMapper.NoticeDelete(id);
    }

    public boolean NoticeUpdata(Announcements announcements){
        return noticeMapper.NoticeUpdata(announcements);
    }

    public Announcements finUpdate(Integer id){
        return noticeMapper.finUpdate(id);
    }
}
